#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse, json, random
def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--src", default="data/mmbench_dev_cn.jsonl", help="source jsonl")
    ap.add_argument("--dst", default="data/mmbench_dev500.jsonl", help="dest jsonl")
    ap.add_argument("--n", type=int, default=500)
    ap.add_argument("--seed", type=int, default=42)
    args = ap.parse_args()

    random.seed(args.seed)
    data = [json.loads(l) for l in open(args.src, "r", encoding="utf-8")]
    if len(data) <= args.n:
        sel = data
    else:
        sel = random.sample(data, args.n)
    with open(args.dst, "w", encoding="utf-8") as f:
        for r in sel:
            f.write(json.dumps(r, ensure_ascii=False) + "\n")
    print(f"Saved {len(sel)} -> {args.dst}")
if __name__ == "__main__":
    main()
